package com.pc.ipushpin.common.util;

import java.io.InputStream;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.PropertyResourceBundle;


public class StwConstant {
	
	private static PropertyResourceBundle props;
	
	private static PropertyResourceBundle dataProps;
	
	public static final int pageSize = 10;
	
	public static final String systemName = "平台";
	
	public static final String accuracy = "%.1f";
	
	//文件大小精度
	public static final String fileAccuracy = "%.2f";
	
	//默认密码
	public static final String defaultPassword = "111111";

	
	public static String IS_FORMAL;
	
	//################ 支付地址  ##############
	public static String WECHAT_PAY_URL;
	public static String WECHAT_REFUND_URL;
	public static String WECHAT_REFUND_SEARCH_URL;
	public static String ALI_PAY_URL;
	public static String ALI_REFUND_URL;
	public static String ALI_REFUND_SEARCH_URL;
	public static String LOCAL_HOST;
	
	//################ 支付参数  ##############
	public static String PAY_PLATFORMID;
	public static String PAY_CHANNELID;
	public static String PAY_TERMINALID;
	public static String PAY_SIGNMETHOD;
	public static String PAY_DATATYPE;
	public static String PAY_VERSION;
	public static String PAY_SECURITYKEY;
	
	//################ 其他参数 ################
	public static String FILE_SERVER_PATH;
	public static String CLOUDWEALTH_MESSAGE_SWITCH;
	public static String CLOUDWEALTH_APIURL;
	public static String CLOUDWEALTH_IMGSERVICE;
	public static String NODEJS_HOST;
	
	//################ 3des密钥 ################
	public static String WALLET_BALANCE_KEY ;
	public static String USER_INFO_KEY ;
	
	//################ 微信公众号参数 ################
	public static String WECHAT_GZ_APP_ID;
	public static String WECHAT_GZ_APP_KEY;
	
	public static String WECHAT_SP_APP_ID;
	public static String WECHAT_SP_APP_KEY;
	
	public static String WECHAT_MCH_ID; //商户id
	public static String WECHAT_MCH_KEY; //商户密钥
	public static String WECHAT_TRADE_TYPE; //交易类型

	public static String TOMCAT_ROOT = "";

	public static String userInfoDesKey = "db8efb0f365ab1a5b05b73cede497180";
	
	//支付查询次数
	public static Map<Integer, Long> SEARCH_COUNT_TIME = new HashMap<Integer, Long>();
	
	//内存保存费率信息
	public static Map<String, Map<String, String>> payChannelMap = new HashMap<String, Map<String, String>>();
	
	static {
		refresh();
	}
	
	public static void refresh() {
		try {
			InputStream fis = StwConstant.class.getClassLoader().getResourceAsStream("system/system_config.properties");
			props = new PropertyResourceBundle(fis);
			
			IS_FORMAL = props.getString("IS_FORMAL");
			
			if("true".equals(IS_FORMAL)){
				InputStream trueFis = StwConstant.class.getClassLoader().getResourceAsStream("system/formal_config.properties");
				dataProps = new PropertyResourceBundle(trueFis);
			} else{
				InputStream falseFis = StwConstant.class.getClassLoader().getResourceAsStream("system/test_config.properties");
				dataProps = new PropertyResourceBundle(falseFis);
			}
			
			FILE_SERVER_PATH = dataProps.getString("FILE_SERVER_PATH");
			
			LOCAL_HOST = dataProps.getString("LOCAL_HOST");
			
			WECHAT_PAY_URL = dataProps.getString("WECHAT_PAY_URL");
			WECHAT_REFUND_URL = dataProps.getString("WECHAT_REFUND_URL");
			WECHAT_REFUND_SEARCH_URL = dataProps.getString("WOYES_REFUND_SEARCH_URL");
			ALI_PAY_URL = dataProps.getString("WOYES_PAY_URL");
			ALI_REFUND_URL = dataProps.getString("WOYES_REFUND_URL");
			ALI_REFUND_SEARCH_URL = dataProps.getString("WOYES_REFUND_SEARCH_URL");
			
			PAY_PLATFORMID = dataProps.getString("PAY_PLATFORMID");
			PAY_CHANNELID = dataProps.getString("PAY_CHANNELID");
			PAY_TERMINALID = dataProps.getString("PAY_TERMINALID");
			PAY_SIGNMETHOD = dataProps.getString("PAY_SIGNMETHOD");
			PAY_DATATYPE = dataProps.getString("PAY_DATATYPE");
			PAY_VERSION = dataProps.getString("PAY_VERSION");
			PAY_SECURITYKEY = dataProps.getString("PAY_SECURITYKEY");
			
			CLOUDWEALTH_MESSAGE_SWITCH = dataProps.getString("CLOUDWEALTH_MESSAGE_SWITCH");
			CLOUDWEALTH_APIURL = dataProps.getString("CLOUDWEALTH_APIURL");
			CLOUDWEALTH_IMGSERVICE = dataProps.getString("CLOUDWEALTH_IMGSERVICE");
			
			WALLET_BALANCE_KEY = dataProps.getString("WALLET_BALANCE_KEY");
			USER_INFO_KEY = dataProps.getString("USER_INFO_KEY");
			NODEJS_HOST= dataProps.getString("NODEJS_HOST");

			WECHAT_GZ_APP_ID = dataProps.getString("WECHAT_GZ_APP_ID");
			WECHAT_GZ_APP_KEY = dataProps.getString("WECHAT_GZ_APP_KEY");
			
			WECHAT_SP_APP_ID = dataProps.getString("WECHAT_SP_APP_ID");
			WECHAT_SP_APP_KEY = dataProps.getString("WECHAT_SP_APP_KEY");
			WECHAT_MCH_ID = dataProps.getString("WECHAT_MCH_ID");
			WECHAT_TRADE_TYPE = dataProps.getString("WECHAT_TRADE_TYPE");
			WECHAT_MCH_KEY = dataProps.getString("WECHAT_MCH_KEY");

			TOMCAT_ROOT = dataProps.getString("tomcat.root.name");
			resetSearchCountTime();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void resetSearchCountTime(){
		if(SEARCH_COUNT_TIME == null){
			SEARCH_COUNT_TIME = new HashMap<Integer, Long>();
		}
		SEARCH_COUNT_TIME.put(0, 10000L);
		SEARCH_COUNT_TIME.put(1, 50000L);
		SEARCH_COUNT_TIME.put(2, 50000L);
		SEARCH_COUNT_TIME.put(3, 100000L);
		SEARCH_COUNT_TIME.put(4, 150000L);
		SEARCH_COUNT_TIME.put(5, 150000L);
		SEARCH_COUNT_TIME.put(6, 300000L);
		SEARCH_COUNT_TIME.put(7, 600000L);
		SEARCH_COUNT_TIME.put(8, 1200000L);
		SEARCH_COUNT_TIME.put(9, 1500000L);
	}
	
	public static void main(String[] args) {
		System.out.println(new Date().getTime());
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(new Date().getTime());
	}
}
